import {take,call,put,fork} from 'redux-saga/effects';
import getGoodsSeachAttr from '../servers/serGoodsSeachAttr';
function *sagWatchGoodsSeachAttr() {
    while (true){
        let action=yield take('ATTR');
        let payload =yield call(getGoodsSeachAttr,action.data);
        let temPayload=payload;
        if (payload.code===200){
           for (let i in temPayload.data){
               temPayload.data[i].checked=false;
               for (let j in temPayload.data[i].param){
                   temPayload.data[i].param[j].checked=false;
               }
           }
        }else {
            temPayload=[]
        }
        yield put({type:'attr',data:{goodsSeachAttr:temPayload}});
        if(action.data.success){
            action.data.success(payload)
        }
    }
}
export default [
    fork(sagWatchGoodsSeachAttr)
]